package top.glkj.hms.controller;

import io.swagger.annotations.Api;
import org.springframework.boot.web.servlet.error.ErrorController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import top.glkj.hms.exception.DefineException;
import top.glkj.hms.utils.StaticValue;

import javax.servlet.http.HttpServletRequest;

/**
 * @author : xgl
 * @version : 0.0.1
 * @date :2021/3/6 16:15
 */
@Controller
@Api(tags = "异常拦截")
public class NotFoundException implements ErrorController {

    @Override
    public String getErrorPath() {
        return "/error";
    }

    @RequestMapping(value = {"/error"})
    public Object error(HttpServletRequest request) throws DefineException {
        Throwable throwable = new Throwable();
        throw new DefineException(StaticValue.NOT_FOUND,new Throwable(request.getRequestURI()));
    }
}